<template>
	<view class="p-b-25">
		<cu-custom title="兴趣班课程设置" bgColor="rgba(255,255,255,0)" ></cu-custom>
		<view class="form-box form-detail bg-white p-15 m-15 ">
			<view class="fl">
				课程名<text class="c-red f-20">*</text>
			</view>
			<view class="right-in f-r">
				<input placeholder="例:2023上半年午托班"/>
			</view>
		</view>
		<view class="m-15 ">
			
			<view class="form-box bg-white m-t-5 ">
				<view class="form-detail bg-white p-15 ">
					<view class="fl">
						招生人数<text class="c-red f-20">*</text>
					</view>
					<view class="right-in f-r flex">
						<input placeholder="请填写招生人数"/>
					</view>
				</view>
				<view class="form-detail   p-15 ">
					<view class="fl">
						托管类别<text class="c-red f-20">*</text>
					</view>
					<view class="right-in f-r flex">
						<view class="uni-list-cell-db">
							<picker @change="bindPickerChange" :value="index" :range="array">
								<view class="uni-input" v-if="index">{{array[index]}}</view>
								<view class="uni-input" v-else style="color: #999;">(午托、晚托、全日托)</view>
							</picker>
						</view><u-icon name="arrow-right" size="34rpx" color='#333'></u-icon>
					</view>
				</view>
				<view class="form-detail bg-white p-15 ">
					<view class="fl">
						授课方式<text class="c-red f-20">*</text>
					</view>
					<view class="right-in f-r flex">
						<input placeholder="请选择授课方式"/><u-icon name="arrow-right" size="34rpx" color='#333'></u-icon>
					</view>
				</view>
				<view class="form-detail   p-15 ">
					<view class="fl">
						性别设置<text class="c-red f-20">*</text>
					</view>
					<view class="right-in f-r flex">
						<view class="uni-list-cell-db">
							<picker @change="bindsexPickerChange" :value="indexsex" :range="arraysex" placeholder="">
								<view class="uni-input" v-if="indexsex ">{{arraysex[indexsex]}}</view>
								<view class="uni-input" v-else style="color: #999;">(仅男生、仅女生)</view>
							</picker>
						</view><u-icon name="arrow-right" size="34rpx" color='#333'></u-icon>
					</view>
				</view>
				<view class="form-detail   p-15 ">
					<view class="fl">
						学期开始时间<text class="c-red f-20">*</text>
					</view>
					<view class="right-in f-r flex">
						<view class="uni-list-cell-db">
							<view class="uni-list-cell-db">
												<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
													<view class="uni-input">{{date}}</view>
												</picker>
											</view>
						</view><u-icon name="arrow-right" size="34rpx" color='#333'></u-icon>
					</view>
				</view>
				<view class="form-detail   p-15 ">
					<view class="fl">
						学期结束时间<text class="c-red f-20">*</text>
					</view>
					<view class="right-in f-r flex">
						<view class="uni-list-cell-db">
							<view class="uni-list-cell-db">
												<picker mode="date" :value="dateend" :start="startDate" :end="endDate" @change="bindDateEndChange">
													<view class="uni-input">{{dateend}}</view>
												</picker>
											</view>
						</view><u-icon name="arrow-right" size="34rpx" color='#333'></u-icon>
					</view>
				</view>
			</view>
			<view class="form-box form-detail bg-white p-15 m-t-15 ">
				<view class="fl">
					食宿费<text class="c-red f-20">*</text>
				</view>
				<view class="right-in f-r">
					<view class="right-in f-r flex">
						<input placeholder="请设置食宿费"/><u-icon name="arrow-right" size="34rpx" color='#333'></u-icon>
					</view>
				</view>
			</view>
			<view class="f-16 m-t-15 p-l-15">课程详情</view>
			<view class="form-box form-detail bg-white p-15 m-t-5 ">
				<textarea placeholder="请输入备注信息"></textarea>
				<text
				                style="position: absolute;
								z-index: 99;
				                right: 70rpx;
								margin-top:-40rpx;
				                font-size:24rpx;
				                color: #999;">{{ start }}/300</text>
			</view>
		</view>
		<view class="uni-form-item uni-column in-text b-t-n b-u-c m-15 m-t-30 c-l m-b-30" style="padding-bottom: 30px;">
			<button> 发布招生信息</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			const currentDate = this.getDate({
			            format: true
			        })
			return {
				start: 0,
				array: ['请选择','午托', '晚托', '全日托'],
				arraysex: ['请选择','仅男生', '仅女生', '男生女生'],
				index: "",
				indexsex: "",
				date: currentDate,
				dateend: currentDate,
			}
		},
		computed: {
		        startDate() {
		            return this.getDate('start');
		        },
		        endDate() {
		            return this.getDate('end');
		        }
		    },
		methods: {
			bindPickerChange: function(e) {
			            console.log('picker发送选择改变，携带值为', e.detail.value)
			            this.index = e.detail.value
			        },
			bindsexPickerChange: function(e) {
			            console.log('picker发送选择改变，携带值为', e.detail.value)
			            this.indexsex = e.detail.value
			        },
			bindDateChange: function(e) {
			            this.date = e.detail.value
			        },
			bindDateEndChange: function(e) {
			            this.dateend = e.detail.value
			        },
			// bindTimeChange: function(e) {
			// 	this.time = e.detail.value
			// },
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
	
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			descInput() {
						let txtVal = this.dataInfo.length;
						this.start = txtVal;
					},
		}
	}
</script>

<style lang="less" scoped>
@import '@/static/css/common.css';
.form-box{border-radius: 10px;}
.form-detail{  display: flow-root; border-bottom: 1px solid #f8f8f8;}
.right-in{ text-align: right;}
</style>